{template 'web/common/common'}
{template 'web/animal/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/layui.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/new-common.css" />

<blockquote class="layui-elem-quote">
    认养订单
</blockquote>
<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>

        <tr>
            <th>ID</th>
            <th>订单编号</th>
            <th>订单总价</th>
            <th>领养数量</th>
            <th>订单状态</th>
            <th>支付方式</th>
            <th>优惠金额</th>
            <th>姓名</th>
            <th>联系电话</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            {loop $list $key $item}
            <td>{$item['id']}</td>
            <td>{$item['order_number']}</td>
            <td>￥{$item['total_price']}</td>
            <td>{$item['count']}</td>
            <td>
                {if $item['status']==1}
                <span class="layui-badge layui-bg-green">已支付</span>
                {else}
                <span class="layui-badge layui-bg-gray">未支付</span>
                {/if}
            </td>
            <td>{$item['pay_method']}</td>
            <td>{$item['coupon_price']}</td>
            <td>{$item['username']}</td>
            <td>{$item['phone']}</td>
            <td>
                <a href="{url 'site/entry/animal',array('m'=>'kundian_farm','op'=>'adopt_order_detail','id'=>$item['id'],'version_id'=>$_GPC['version_id'])}">
                    <button class="layui-btn layui-btn-sm"><i class="layui-icon"></i></button>
                </a>
                {if $item['status']==0}
                <button type="button" data-id="{$item['id']}" class="layui-btn layui-btn-sm delete_adopt_order"><i class="layui-icon"></i></button>
                {/if}
            </td>

        </tr>
        {/loop}
        </tbody>
    </table>
    <div style="text-align: right;">
    {$pager}
    </div>
</div>
<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            //删除
            $(".delete_adopt_order").click(function(){
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '确定删除吗?',
                    text: "确定删除吗?",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '删除',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'delete_adopt_order','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('操作成功!', '操作成功!', 'success');
                                    that.parent().parent().remove();
                                }else{
                                    swal('操作失败!', '操作失败!', 'error');
                                }
                            }
                        })
                    }
                })
            });
        })
    })
</script>